home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d18
/
string.arc
/
TXTFMT.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1991-04-28
|
1KB
|
40 lines
program testformat;
uses crt,strings;
const maxlines=10;
var s:array [1..maxlines] of string;
t1:string;
i,len,lins,p:byte;
begin
i:=0;
writeln('This program will accept up to 10 lines of text and print it');
writeln('out as a right- and left-justified paragraph.');
repeat
inc(i);
writeln('Enter line ',i,', or a null to end input: '); readln(s[i]);
s[i]:=space(s[i],1);
until (s[i]='') or (i=maxlines) ;
if s[i]='' then dec(i);
lins:=i;
len:=30;
while len<80 do begin
writeln(copies('----+',len div 5));
i:=0; t1:='';
while i<lins do begin
while (length(t1)<=len) and (i<lins) do begin
inc(i);
t1:=t1+s[i]+' ';
end;
while length(t1)>len do begin
p:=lastpos(' ',t1,len+1);
writeln(justify(left(t1,p,' '),len));
t1:=right(t1,length(t1)-p,' ');
end;
end;
writeln(t1);
writeln('Press enter to continue ...'); readln;
len:=len+20;
end;
end.